<!--<?php
print <<<EOT
-->
<div class="m"></div>
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="tr4">
    <td><input type="button" name="Submit" value="新增采集规则" onclick="window.location='$basename&action=add';" class="btn">
      <input type="button" name="Submit2" value="查看所有规则" onclick="window.location='$basename';"  class="btn"></td>
  </tr>
</table>
</div>
<!--
EOT;
if(!$action){
print <<<EOT
-->
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="head">
    <td colspan="7">站点采集规则一览</td>
    </tr>
  <tr class="tr2">
    <td width="3%">&nbsp;</td>
    <td>ID</td>
    <td>规则名称</td>
    <td>{$very[contentName]}模型</td>
    <td>采集操作</td>
    <td>规则管理</td>
  </tr>
<!--
EOT;
foreach($gather as $value){
print <<<EOT
-->
  <tr class="tr3">
    <td><img src="images/admin/gat.gif" align="absmiddle" alt="改名" /></td>
    <td>$value[gid]</td>
    <td>$value[gname]</td>
    <td>$value[module]</td>
    <td>
	<a href="javascript:void(0);" onClick="gather('$value[gid]','0');"><img src="images/admin/start.gif" alt="开始采集" border="0" align="absmiddle" /></a> &nbsp;
	<a href="$basename&action=view&gid=$value[gid]"><img src="images/admin/view.gif" alt="查看" border="0" align="absmiddle" /></a>&nbsp;
	<a href="javascript:void(0);" onClick="gather('$value[gid]','1');"><img src="images/admin/test.gif" alt="采集测试" border="0" align="absmiddle" /></a> &nbsp;
	</td>
    <td><a href="$basename&action=edit&gid=$value[gid]"><img src="images/admin/edit.png" alt="编辑" border="0" align="absmiddle" /></a>&nbsp;
	<a href="javascript:void(0);" onclick="return delgather($value[gid]);"><img src="images/admin/delete.png" alt="删除" border="0" align="absmiddle" /></a>
	&nbsp;<a href="$basename&action=export&gid=$value[gid]"><img src="images/admin/export.gif" alt="导出" border="0" align="absmiddle"  /></a></td>
  </tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="head">
    <td>导入采集规则</td>
    </tr>
<form action="$basename" method="post" enctype="multipart/form-data">
  <tr class="line">
    <td>请选择要导入的文件&nbsp;&nbsp;
    	<input name="xmlfile" type="file" class="input" id="xmlfile" size="30" />
      	<select name="mid" id="mid">
      		<option value="">请选择{$very[contentName]}模型</option>

		$module_select

      	</select>
      	<input name="action" type="hidden" id="action" value="import" />      	<input type="submit" name="Submit5" value="导入" class="btn" /></td>
    </tr>
</form>
</table>
</div>
<div id="msg" style="border:#69788c 1px solid; background-color:#fdfdfd;padding:3px; width:400px;position:absolute; top:100px; left:150px; display:none;">
<div style="height:20px; padding:3px;"><img src="images/admin/ing.gif" align="absmiddle" /> 采集中，请耐心等待.....</div>
<div id="operate" style=" border:#ffc467 1px solid; color:#46618c; background-color:#ffeda1;line-height:150%;overflow:auto;display:none; padding:5px;">
已经开始进行采集，请耐心等待.....
</div>
</div>
<script language="javascript" src="script/xhr.js"></script>
<script language="javascript">
var gathering = 0;

/*
var stopgather = function (){
	if(gathering){
		confirm("您确定要离开此页面么？");
	}
}
document.body.onbeforeunload = stopgather;
*/

function delgather(gid){
	var msg=confirm("如果您删除该采集规则，那么所有该采集规则下的未入库{$very[contentName]}也将被清除，您确认删除么？");
	if(msg){
		var x = new XHR('del');
		x.get("$basename&action=del&gid="+gid);
	}else{
		return false;
	}
}
function del(ret){
	if(ret=='100'){
		window.location.reload();
	}else{
		alert('出现异常错误，删除失败');
	}
}
var url = "$basename";
var contentType = "application/x-www-form-urlencoded; charset=$charset";
</script>
<script language="javascript" src="script/gather.js"></script>
<!--
EOT;
}elseif($action=='add' || $action=='edit'){
print <<<EOT
-->
<form action="$basename" method="post" name="FORM" >
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="head">
    <td colspan="2">采集规则管理</td>
    </tr>
  <tr class="tr2">
    <td colspan="2">(*您无法将一个{$very[contentName]}模型的采集{$very[contentName]}添加到另外一个{$very[contentName]}模型的目录中去,请选择正确的{$very[contentName]}模型再来进行编辑)</td>
    </tr>
  <tr class="line">
    <td width="25%">采集{$very[contentName]}模型</td>
    <td width="75%">
     <select name="mid" $ifchange onchange="window.location='$basename&action=add&mid='+this.value;">
	  $module_select
     </select></td>
  </tr>
  <tr class="line">
    <td>采集规则名称</td>
    <td><input name="gname" type="text" class="input" id="gname" value="$gname" /></td>
  </tr>
  <tr class="line">
    <td>是否过滤已采集过的网址</td>
    <td><input type="radio" name="filtreit" value="1" $filtreit_Y />
      过滤
        <input type="radio" name="filtreit" value="0" $filtreit_N />
        不过滤</td>
  </tr>
  <tr class="line">
    <td>采集某段时间之前采集过的网址</td>
    <td><input name="ignoretime" type="text" class="input" id="ignoretime" value="$ignoretime" size="5" />
      天</td>
  </tr>
  <tr class="line">
    <td>关键替换(增加替换规则数量)</td>
    <td><input name="replacenum" type="text" class="input" id="replacenum" value="$strNum" size="10"> <input type="button" name="Submit5" value="增加" class="btn" onclick="MakeStr();" /></td>
  </tr>
  <tr class="line">
    <td>关键字替换规则</td>
    <td>原始字段:
      <input name="str1_1" type="text" class="input" id="str1_1" value="$str1[1]" />
      目标字段:
      <input name="str2_1" type="text" class="input" id="str2_1" value="$str2[1]" />
      <br />
<span id='replace'>
</span></td>
  </tr>
  <tr class="line">
    <td>采集形式</td>
    <td><input type="radio" name="multi" value="0" onclick="showType('single');" $multi_N />
      单条网址
        <input type="radio" name="multi" value="1" onclick="showType('multiurl');" $multi_Y />
        批量多页</td>
  </tr>
  </table>
  <div id="single" style="display:none">
  <table width="100%" cellpadding="0" cellspacing="0">
  <tr class="line">
    <td width="25%">采集来源网址<br />
      (一行一个网址)</td>
    <td width="75%"><textarea name="fromurl" cols="80" rows="5" id="fromurl">$fromurl</textarea></td>
  </tr>
  </table>
  </div>
  <div id="multiurl" style="display:none">
  <table width="100%" cellpadding="0" cellspacing="0">
  <tr class="line">
    <td width="25%">列表页多页类似地址形式<br />
      (如果不需要采集多页,可留空)</td>
    <td width="75%"><textarea name="listurl" cols="80" rows="5" id="listurl">$listurl</textarea>(页码部分用{DATA}表示)</td>
  </tr>
  <tr class="line">
    <td>多页数字变化规则</td>
    <td>从
      <input name="startpage" type="text" class="input" id="startpage" value="$startpage" size="5" />
      到
      <input name="endpage" type="text" class="input" id="endpage" value="$endpage" size="5" /></td>
  </tr>
  </table>
  </div>
  <table width="100%" cellpadding="0" cellspacing="0">
  <tr class="line">
    <td width="25%">列表页有效区域</td>
    <td width="75%"><textarea name="listarea" cols="80" rows="5" id="listarea">$listarea</textarea>
      有效部分用{DATA}标识</td>
  </tr>
  <tr class="line">
    <td>有效网址必须包含的字符</td>
    <td><textarea name="contenturl" cols="80" rows="5" id="debarurl">$contenturl</textarea>
      (多个{$very[contentName]}用|区分)</td>
  </tr>
  <tr class="line">
    <td>有效网址必须排除的字符</td>
    <td><textarea name="debarurl" cols="80" rows="5" id="debarurl">$debarurl</textarea>
      (多个{$very[contentName]}用|区分)</td>
  </tr>
  <tr class="line">
    <td width="25%">{$very[contentName]}页分页地址区域<br />(此区域中不可包含其他链接)</td>
    <td width="75%"><textarea name="pageurl" cols="80" rows="5" id="pageurl">$pageurl</textarea>
      有效部分用{DATA}标识</td>
  </tr>
  <tr class="line">
  	<td>&nbsp;</td>
  	<td>&nbsp;</td>
  	</tr>
<!--
  <tr class="line">
    <td>列表页分页区域</td>
    <td><textarea name="pagearea" cols="80" rows="5" id="pagearea">$pagearea</textarea></td>
  </tr>
-->
  </table>
</div>
<div class="t">
  <table width="100%" cellpadding="0" cellspacing="0">
  <tr class="head">
    <td colspan="2">{$very[contentName]}页面采集规则</td>
   </tr>
  <tr class="tr2">
    <td>规则名</td>
   	<td>规则细则</td>
  </tr>
<!--
EOT;
foreach($modrule as $gather){
print <<<EOT
-->
  <tr class="line">
    <td width="25%">{$gather[fieldname]}采集规则</td>
    <td width="75%"><textarea name="fieldrule[$gather[fieldid]]" cols="80" rows="5">$gather[fieldrule]</textarea>
    有效{$very[contentName]}用{DATA}标识</td>
  </tr>
  <tr class="line">
  	<td>{$gather[fieldname]}处理规则</td>
  	<td><input name="imgtolocal[$gather[fieldid]]" type="checkbox" value="1" $gather[imgtolocal] />
  		图片本地化  <span style="color:#FF0000">图片本地化将严重影响采集速度</span><br />
  		<input name="ifclearhtml[$gather[fieldid]]" type="checkbox" id="fieldname" value="1" $gather[ifclearhtml] />
  		清除多余HTML标签（保留如下标签）<span style="color:#FF0000;">影响采集速度</span><br />
		<div>$gather[htmlmark]</div>

		</td>
  	</tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<div class="sub">
  <input type="submit" name="Submit3" value="提交" class="btn" />
  <input name="gid" type="hidden" id="gid" value="$gid" />
   <input name="step" type="hidden" id="step" value="2" />
  <input name="action" type="hidden" id="action" value="$action" />
</div>
</form>
<script language="javascript">
var str1 = new Array();
var str2 = new Array();
<!--
EOT;
for($i=1;$i<=10;$i++){
$str1[$i] = addslashes($str1[$i]);
$str2[$i] = addslashes($str2[$i]);
print <<<EOT
-->
str1[$i] = '$str1[$i]';
str2[$i] = '$str2[$i]';
<!--
EOT;
}if($multi){
print <<<EOT
-->
showType('multiurl');
<!--
EOT;
}else{
print <<<EOT
-->
showType('single');
<!--
EOT;
}print <<<EOT
-->
function showType(value){
	if(value=='single'){
		var other = 'multiurl';
	}else{
		var other = 'single';
	}
	document.getElementById(other).style.display='none';
	document.getElementById(value).style.display='';
}
var startNum = 2;
MakeStr();
function MakeStr()
{
   var upfield = document.getElementById("replace");
   var addNum = document.FORM.replacenum.value;
   if(addNum=='') addNum=1;
   addNum = parseInt(addNum);
   var endNum =  addNum+startNum;
   if(endNum>11) endNum = 11;
   for(startNum;startNum<endNum;startNum++){
	   upfield.innerHTML += "原始字段: <input type='text' name='str1_"+startNum+"' class='input' value=\""+str1[startNum]+"\" /> 目标字段: <input type='text' name='str2_"+startNum+"' class='input' value=\""+str2[startNum]+"\" /> <br/>";
   }
	 document.FORM.replacenum.value='';
}
function ResetUpload()
{
   var upfield = document.getElementById("uploadfield");
   upfield.innerHTML = "";
   startNum = 4;
}
</script>
<!--
EOT;
}elseif($action=='view'){
print <<<EOT
-->
<form action="$basename" method="post" name="gat">
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="head">
    <td colspan="7">$gname 采集结果</td>
    </tr>
  <tr class="tr2">
    <td>&nbsp;</td>
    <td>序号</td>
    <td>标题</td>
    <td>采集时间</td>
    <td>采集者</td>
    <td>操作</td>
    <td>&nbsp;</td>
  </tr>
<!--
EOT;
$i=$start;
foreach($contentdb as $value){
$i++;
print <<<EOT
-->
  <tr class="tr3">
    <td><input name="tids[]" type="checkbox" id="tids[]" value="$value[tid]" /></td>
    <td>$i</td>
    <td><a href="$value[url]" target="_blank">$value[title]</a></td>
    <td>$value[postdate]</td>
    <td>$value[publisher]</td>
    <td><a href="$basename&action=delgather&tid=$value[tid]&mid=$mid&gid=$gid">删除</a></td>
    <td>&nbsp;</td>
  </tr>
<!--
EOT;
}print <<<EOT
-->
</table>
</div>
<div class="t">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr class="tr4">
    <td><select name="method" id="method"  onchange="showTarget(this.value);">
      <option value="delgather">删除</option>
      <option value="usegather" selected="selected">入库</option>
    </select>
	<span id='target'>
    目标:
      <select name="tocid" id="tocid" >
	$cate_select
	</select>
	<input type="checkbox" name="useall" value="1" />入库全部采集
	</span>
      <input name="fromcid" type="hidden" id="fromcid" value="$cid" />
      <input name="gid" type="hidden" id="gid" value="$gid" />
      <input name="action" type="hidden" id="action" value="whole" />
    <input type="button" name="Submit3" value="全选" class="btn" onclick="CheckAll(document.gat);" />
    <input type="submit" name="Submit4" value="提交" class="btn" /></td>
    <td style="text-align:right">$pages</td>
  </tr>
</table>
</div>
</form>
<script language="javascript">
function showTarget(id){
	var target = document.getElementById('target');
	if(id=='usegather'){
		target.style.display='';
	}else{
	 	target.style.display='none';
	}
}
</script>
<!--
EOT;
}
?>-->